/**
 * @file bull_hal_sys_thread.h
 * @brief 
 * @author yejing (yejh@gongniu.cn)
 * @version 1.0
 * @date 2024-05-09
 * 
 * Copyright 2021-2023 GongNiu Inc. All Rights Reserved.
 * 
 */



#ifndef __BULL_HAL_SYS_THREAD_H__
#define __BULL_HAL_SYS_THREAD_H__

#include "bull_hal_adapter.h"

#ifdef __cplusplus
extern "C" {
#endif

/**
 * @brief 创建线程
 * @param  thrd_param       My Param doc
 * @return int 
 */
OPERATE_RET bull_hal_sys_thread_create( THREAD_FUNC_T func,const char* name, unsigned int stack_size,void* arg,unsigned int priority, THREAD_HANDLE* thread ) ;


/**
 * @brief 删除线程
 * @param  thread  线程句柄
 */
OPERATE_RET bull_hal_sys_thread_delete( THREAD_HANDLE thread );

OPERATE_RET bull_hal_sys_thread_spiram_create( THREAD_FUNC_T func, const char* name, unsigned int stack_size, void* arg, unsigned int priority, THREAD_HANDLE* thread );

OPERATE_RET bull_hal_sys_thread_spiram_delete( THREAD_HANDLE thread );

/**
 * @brief 判断传入进去的任务句柄是否为当前任务
 * @return THREAD 
 */
OPERATE_RET bull_hal_sys_thread_is_self(THREAD_HANDLE thread, BOOL_T* is_self);


/**
 * @brief get thread stack's watermark
 * 
 * @param[in] thread    the thread handle
 * @param[out] watermark  watermark in Bytes
 * @retval OPRT_OK      success
 * @retval Other        fail  uxTaskGetStackHighWaterMark
 */
OPERATE_RET bull_hal_sys_thread_get_stack_hight_watermark( THREAD_HANDLE thread, UINT_T* watermark );


/**
* @brief set thread priority
*
* @param[in] thread       the input thread handle
* @param[in] prio_thread  the priority thread send to
* @retval void    
*/
void bull_hal_sys_thread_set_priority(THREAD_HANDLE thread, INT_T prio_thread);

/**
* @brief get thread priority
*
* @param[in]  thread     the input thread handle
* @param[out] priority   the priority of thread
* @retval void
*/
INT_T bull_hal_sys_thread_get_priority( THREAD_HANDLE thread );



#ifdef __cplusplus
}
#endif /* __cplusplus */


#endif